//index.js
//获取应用实例
var app = getApp()
var util = require("../../utils/util.js")
Page({
  data: {
    //motto: 'Hello World',
    userInfo: {},
    dateTime:{}
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: 'pages/logs/logs'
    })
  },
  onLoad: function () {
   var that = this
    //调用应用实例的方法获取全局数据
      app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo,
        dateTime:that.getTimeStr()
      })
    })
    
  },
  getTimeStr:function(){
    var hours = new Date().getHours()
    var timeWhile = {}
    if(hours > 6 && hours <=9 ){
      timeWhile = {message:"一日之计在于晨",slot:"earlyMorning"}
    }else if(hours>9 && hours <= 11){
      timeWhile = {message:"上午好",slot:"morning"}
    }else if (hours > 11 && hours <= 13){
      timeWhile = {message:"中午好",slot:"noon"}
    }else if (hours > 13 && hours <= 18){
      timeWhile = {message:"一日之计在于晨,早安",slot:"afterNoon"}
    }else if (hours > 18 && hours <=21 ){
      timeWhile = {message:"晚上好",slot:"night"}
    }else{
      timeWhile = {message:"大半夜的你要长肉么",slot:"lateNight"}
    }
      return timeWhile
  },
  checkMe:function(e){
    console.log("pages/"+e.target.dataset.uri);
    wx.reLaunch({
      url: "pages/index/why/index?"+e.target.dataset.uri,
      success: function(res){
        // success
      },
      fail: function(res) {
        // fail
      },
      complete: function(res) {
        // complete
      }
    })
  }
})

